#include <iostream>
#include <stdlib.h>
#include <string>

static const char *skip_spaces(const char *s)
{
    while (*s == ' ')
        s++;
    return s;
}

static double evaluate(const char *s, const char **pend)
{
    s = skip_spaces(s);

    /* Is it a (p e1 e2) expression? */
    if (*s == '(')
    {
        double p = strtod(s + 1, (char **)&s);
        double e1 = evaluate(s, &s);
        double e2 = evaluate(s, &s);
        s = skip_spaces(s);
        s++;        /* skip ')' */
        if (pend)
            *pend = s;
        return p * (e1 + e2) + (1 - p) * (e1 - e2);
    }
    else
    {
        return strtod(s, (char **)pend);
    }
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::string line;
    while (std::getline(std::cin, line) && line != "()")
    {
        printf("%.2lf\n", evaluate(line.c_str(), NULL));
    }
    return 0;
}
